﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace Teat
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList arr = new ArrayList() { "abc", "bac", "cba", 111, 222, 333, };
            int index = arr.IndexOf("EGM");
            if (index != -1)
            {
                Console.WriteLine("EGM EGM -!!!");
            }
            else
            {
                Console.WriteLine("海起来！！！");
            }
            Console.WriteLine();

            //将集合arr的原数添加到另一个集合
            ArrayList arr1 = new ArrayList() { "EDM", "edm", "abc", 857, 134 };
            ArrayList newList = new ArrayList();
            for (int i = 0; i < arr1.Count; i = i + 2)
            {
                newList.Add(arr1[i]);
            }
            foreach (var b in newList)
            {
                Console.WriteLine(b);
            }
            Console.WriteLine();
            //在集合元数后面插入三个数
            ArrayList array  = new ArrayList() { 123, 456, 785 };
            arr.InsertRange(1, array);
            foreach (var f in arr)
            {
                Console.WriteLine(f);
            }
            Console.WriteLine();

            //使用sort将集合的原数排序
            array.Sort();
            foreach (var g in array)
            {
                Console.WriteLine(g);
            }
            Console.WriteLine();

            //使用icomparer排序输出String

            MyComparer n = new MyComparer();
            array.Sort();
            foreach (var q in array)
            {
                Console.WriteLine(q);
            }
            Console.WriteLine();
        }
    }
}
